$(document).ready(function () {
    smrzxx.onLoad();
})

var smrzxx = (function () {

    var init = function () {

    }

    return {
        onLoad: function () {
            init();
            var curseg = smrzxx;
            curseg.onChange();
        },

        //循环绑定改变图片事件
        onChange: function () {

            for (var i = 0; i < $('.wxn_sm_sfphoto li').length; i++) {
                (function (i) {
                    $(".file").eq(i).change(function () {
                        var fileImg = $(".fileImg").eq(i);
                        var explorer = navigator.userAgent;
                        var imgSrc = $(this)[0].value;
                        if (explorer.indexOf('MSIE') >= 0) {
                            if (!/\.(jpg|jpeg|png|JPG|PNG|JPEG)$/.test(imgSrc)) {
                                imgSrc = "";
                                fileImg.attr("src", "/img/default.png");
                                return false;
                            } else {
                                fileImg.attr("src", imgSrc);
                            }
                        } else {
                            if (!/\.(jpg|jpeg|png|JPG|PNG|JPEG)$/.test(imgSrc)) {
                                imgSrc = "";
                                fileImg.attr("src", "/img/default.png");
                                return false;
                            } else {
                                var file = $(this)[0].files[0];
                                var url = URL.createObjectURL(file);
                                fileImg.attr("src", url);
                            }
                        }
                    })
                })(i);

            }
        }

    }
})();